#include <bits/stdc++.h>
#define N (int)1e5+5
using namespace std;
int T;
int n,m,l,vs;
int d[N];
double p[N];
struct node{int d,v,a;}c[N];
inline void process()
{
    scanf("%d%d%d%d",&n,&m,&l,&vs);
    for(int i=1;i<=n;++i) scanf("%d%d%d",&c[i].d,&c[i].v,&c[i].a);
    for(int i=1;i<=m;++i) scanf("%lf",&p[i]);
    int res1=0,res2=0,lft=0,rgt=m;
    for(int i=1;i<=n;++i)
    {
        int k=lower_bound(p+1,p+m+1,c[i].d)-p;
        if(k==m+1) continue;
        if(c[i].a>=0)
        {
            if(vs*vs-c[i].v*c[i].v+2*c[i].a*c[i].d<2*c[i].a*p[m])
            {
                res1++;
                double pos=c[i].d*1.0+1.0*(vs*vs-c[i].v*c[i].v)/(2*c[i].a);
                int t=upper_bound(p+1,p+m+1,pos)-p;
                d[t]++;
            }
        }
        else
        {
            if(vs*vs-c[i].v*c[i].v+2*c[i].a*c[i].d<2*c[i].a*p[k])
            {
                res1++;
                double pos=c[i].d*1.0+1.0*(vs*vs-c[i].v*c[i].v)/(2*c[i].a);
                int t=lower_bound(p+1,p+m+1,pos)-p;
                d[k]++,d[t]--;
            }
        }
    }
    for(int i=1;i<=n;++i) d[i]+=d[i-1];
    int cnt=1;
    for(int i=1;i<=n;++i)
        if(d[i]==0 && d[i+1]>0) cnt++;
    res2=(res1==0)?m:m-cnt;
    printf("%d %d\n",res1,res2);
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--) process();
    return 0;
}